package edu.gatech.ors.mrsim.core;

/**
 * Represents an event at a single point in time.
 * @author tdoneal
 *
 */
public abstract class Event implements Comparable{

    //the timestamp, in ms, when this event occurred
    protected long timeStamp;
    
    //the originating module
    protected ModuleSimulator module;
    
    /**
     * Constructor
     * @param timeStamp Timestamp of this event
     */
    public Event(ModuleSimulator sourceModule,long timeStamp){
	this.timeStamp = timeStamp;
	this.module = sourceModule;
    }
    
    /**
     * Event e1 is "greater than" event e2 iff e1.getTimeStamp()>e2.getTimeStamp().  This lets 
     * PriorityQueue work as expected.
     */
    public int compareTo(Object o) {
	Event e = (Event)o;
	int rv =  (int) (timeStamp-e.timeStamp);
	//System.out.println("cte: rv = "+rv);
	return rv;
    }
    
    public long getTimeStamp(){
	return timeStamp;
    }
    
}
